<template>
  <div>
    <div class="printhead">
      <div class="head">
        <div style="float:left">
          学生综合信息
        </div>
        <div style="float:right">
          <a :href="('./api/managerInfo/studentAllInfoDownWord/' + this.$route.query.sn)"
             v-if="this.$route.query.type ==='1'">
            <el-button type="primary"
                       size='small'>导出word</el-button>
          </a>
          <!-- <el-button type="primary"
                     size="small">导出pdf</el-button> -->
          <a :href="('./api/managerInfo/studentAllInfoHistoryDownWord/{sn}' + this.$route.query.sn)"
             v-if="this.$route.query.type ==='2'">
            <el-button type="primary"
                       size='small'>导出word</el-button>
          </a>
        </div>
      </div>
    </div>
    <div class="content">
      <div class='tablecontent'>
        <h2 class="pt20">学生综合信息</h2>
        <table border="1">
          <tr>
            <th colspan="9"
                class="title">基本信息</th>
          </tr>
          <tr>
            <th>学号</th>
            <td colspan="2">{{ basicInformation.sn }}</td>
            <th>姓名</th>
            <td colspan="2">{{ basicInformation.name }}</td>
            <td colspan="3"
                rowspan="9">
              <img :src="'data:image/gif;base64,'+ this.picUrl"
                   v-if=" this.picUrl "
                   style="width:295px;height:413px"></td>
          </tr>
          <tr>
            <th>曾用名</th>
            <td colspan="2">{{basicInformation.formerName}}</td>
            <th>性别</th>
            <td colspan="2">{{basicInformation.gender}}</td>
          </tr>
          <tr>
            <th>民族</th>
            <td colspan="2">{{basicInformation.nation}}</td>
            <th>政治面貌</th>
            <td colspan="2">{{basicInformation.politicsStatus}}</td>
          </tr>
          <tr>
            <th>籍贯</th>
            <td colspan="2">{{basicInformation.nativePlace}}</td>
            <th>身份证号</th>
            <td colspan="2">{{basicInformation.idNumber}}</td>
          </tr>
          <tr>
            <th>出生日期</th>
            <td colspan="2">{{basicInformation.birthDate}}</td>
            <th>健康状况</th>
            <td colspan="2">{{basicInformation.healthState}}</td>
          </tr>
          <tr>
            <th>血型</th>
            <td colspan="2">{{basicInformation.bloodType}}</td>
            <th>宗教信仰</th>
            <td colspan="2">{{basicInformation.religion}}</td>
          </tr>
          <tr>
            <th>现在户口所在地</th>
            <td colspan="2">{{basicInformation.currentDomicilePlace}}</td>
            <th>火车乘车区间</th>
            <td colspan="2">{{basicInformation.departurePlace}}-{{basicInformation.destinationPlace}}</td>
          </tr>
          <tr>
            <th>婚姻状况</th>
            <td colspan="2">{{basicInformation.maritalStatus}}</td>
            <th>与学校联名银行卡账户</th>
            <td colspan="2">{{basicInformation.openingBank}}</td>
          </tr>
          <tr>
            <th>银行卡号</th>
            <td colspan="2">{{basicInformation.bankCard}}</td>
            <th>特长爱好</th>
            <td colspan="2">{{basicInformation.hobby}}</td>
          </tr>
          <tr>
            <th>校园一卡通</th>
            <td colspan="2">{{basicInformation.metroCard}}</td>
            <th>辅导员姓名</th>
            <td colspan="2">{{allinformation.instructor}}</td>
            <th>班主任姓名</th>
            <td colspan="2">{{allinformation.classTeacher}}</td>
          </tr>
          <tr>
            <th>身高(cm)</th>
            <td colspan="2">{{basicInformation.stature}}</td>
            <th>体重(kg)</th>
            <td colspan="2">{{basicInformation.weight}}</td>
            <td></td>
            <td colspan="2"></td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">学籍信息</th>
          </tr>
          <tr>
            <th>所属学院</th>
            <td colspan="2">{{education.collegeName}}</td>
            <th>所属专业</th>
            <td colspan="2">{{education.majorName}}</td>
            <th>所属年级</th>
            <td colspan="2">{{education.grade}}</td>
          </tr>
          <tr>
            <th>所属班级</th>
            <td colspan="2">{{education.className}}</td>
            <th>生源类型</th>
            <td colspan="2">{{education.sourceType}}</td>
            <th>学籍状态</th>
            <td colspan="2">{{education.educationStatus}}</td>
          </tr>
          <tr>
            <th>学生类型</th>
            <td colspan="2">{{education.education}}</td>
            <th>是否在籍</th>
            <td colspan="2">{{education.absentee}}</td>
            <th>是否在校</th>
            <td colspan="2">{{education.atSchool}}</td>
          </tr>
          <tr>
            <th>毕业时间（预计）</th>
            <td colspan="2">{{education.graduateDate}}</td>
            <th></th>
            <td colspan="2"></td>
            <th></th>
            <td colspan="2"></td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">入学信息</th>
          </tr>
          <tr>
            <th>入学年月</th>
            <td colspan="2">{{education.enterDate}}</td>
            <th>入学前户口所在地</th>
            <td colspan="2">{{education.domicilePlace}}</td>
            <th>生源地</th>
            <td colspan="2">{{education.sourcePlace}}</td>
          </tr>
          <tr>
            <th>入学前就读中学</th>
            <td colspan="2">{{education.highSchool}}</td>
            <th>高考分数</th>
            <td colspan="2">{{education.satScores}}</td>
            <th>邮寄录取通知书家庭地址</th>
            <td colspan="2">{{education.mailHomeAddres}}</td>
          </tr>
          <tr>
            <th>邮寄录取通知书收件人姓名</th>
            <td colspan="2">{{education.addresseeName}}</td>
            <th>邮寄录取通知书收件人电话</th>
            <td colspan="2">{{education.addresseePhone}}</td>
            <th></th>
            <td colspan="2"></td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">通讯信息</th>
          </tr>
          <tr>
            <th>宿舍分布区</th>
            <td colspan="2">{{allinformation.dormitoryArea}}</td>
            <th>寝室号</th>
            <td colspan="2">{{allinformation.studentDorm}}</td>
            <th>联系电话</th>
            <td colspan="2">{{contact.phone}}</td>
          </tr>
          <tr>
            <th>备用电话</th>
            <td colspan="2">{{contact.standbyPhone}}</td>
            <th>微信号</th>
            <td colspan="2">{{contact.wechat}}</td>
            <th>QQ号码话</th>
            <td colspan="2">{{contact.qq}}</td>
          </tr>
          <tr>
            <th>邮箱</th>
            <td colspan="2">{{contact.email}}</td>
            <th>家庭电话</th>
            <td colspan="2">{{contact.familyPhone}}</td>
            <th>家庭电子邮箱</th>
            <td colspan="2">{{contact.familyEmail}}</td>
          </tr>
          <tr>
            <th>家庭所在地区</th>
            <td colspan="8">{{contact.familyPlace}}</td>
          </tr>
          <tr>
            <th>家庭详细地址</th>
            <td colspan="8">{{contact.familyDetailAddress}}</td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">家庭信息</th>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>父母类
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>关系</td>
            <td>姓名</td>
            <td>联系电话</td>
            <td>出生日期</td>
            <td>学历</td>
            <td>政治面貌</td>
            <td>工作单位</td>
            <td>职务</td>
          </tr>
          <tr v-for="(parent,index) in parents"
              :key="'info14'+index">
            <td>{{index+1}}</td>
            <td>{{parent.relation}}</td>
            <td>{{parent.name}}</td>
            <td>{{parent.phone}}</td>
            <td>{{parent.birthDate}}</td>
            <td>{{parent.education}}</td>
            <td>{{parent.politicsStatus}}</td>
            <td>{{parent.workUnit}}</td>
            <td>{{parent.duty}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>直系亲属类
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>关系</td>
            <td>姓名</td>
            <td>联系电话</td>
            <td>出生日期</td>
            <td>学历</td>
            <td>政治面貌</td>
            <td>工作单位</td>
            <td>职务</td>
          </tr>
          <tr v-for="(consanguinity,index) in consanguinitys"
              :key="'info1'+index">
            <td>{{index+1}}</td>
            <td>{{consanguinity.relation}}</td>
            <td>{{consanguinity.name}}</td>
            <td>{{consanguinity.phone}}</td>
            <td>{{consanguinity.birthDate}}</td>
            <td>{{consanguinity.education}}</td>
            <td>{{consanguinity.politicsStatus}}</td>
            <td>{{consanguinity.workUnit}}</td>
            <td>{{consanguinity.duty}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>其他社会重要联系人类
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>关系</td>
            <td>姓名</td>
            <td>联系电话</td>
            <td>出生日期</td>
            <td>学历</td>
            <td>政治面貌</td>
            <td>工作单位</td>
            <td>职务</td>
          </tr>
          <tr v-for="(linkman, index) in linkmans"
              :key="'info2'+index">
            <td>{{index+1}}</td>
            <td>{{linkman.relation}}</td>
            <td>{{linkman.name}}</td>
            <td>{{linkman.phone}}</td>
            <td>{{linkman.birthDate}}</td>
            <td>{{linkman.education}}</td>
            <td>{{linkman.politicsStatus}}</td>
            <td>{{linkman.workUnit}}</td>
            <td>{{linkman.duty}}</td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">奖惩情况</th>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>奖学金
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>申请学年</td>
            <td colspan="4">评定结果</td>
            <td>资助金额</td>
            <td colspan="2"></td>
          </tr>
          <tr v-for="(scholarship, index) in scholarships"
              :key="'info3'+index">
            <td>{{index+1}}</td>
            <td>{{scholarship.year}}</td>
            <td colspan="4">{{scholarship.result}}</td>
            <td>{{scholarship.money}}</td>
            <td colspan="2"></td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>国家励志奖学金
            </td>
          </tr>
          <tr>
          <tr>
            <td>序号</td>
            <td>学年</td>
            <td colspan="4">评定结果</td>
            <td>资助金额</td>
            <td colspan="2"></td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td colspan="4"></td>
            <td></td>
            <td colspan="2"></td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>违纪处分
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>处分期限</td>
            <td colspan="4">违纪种类</td>
            <td>是否已撤销</td>
            <td colspan="2">处分添加时间</td>
          </tr>
          <tr v-for="(violation, index) in violations"
              :key="'info15'+index">
            <td>{{ index+1 }}</td>
            <td>{{ violation.punishLimit }}</td>
            <td colspan="4">{{ violation.typeName }}</td>
            <td>{{ violation.state }}</td>
            <td colspan="2">{{ violation.createDate }}</td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">资助情况</th>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>困难认定
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>学年</td>
            <td colspan="6">评定结果</td>
            <td></td>
          </tr>
          <tr v-for="(identify, index) in identifys"
              :key="'info4'+index">
            <td>{{index+1}}</td>
            <td>{{identify.year}}</td>
            <td colspan="6">{{identify.result}}</td>
            <td></td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>助学金
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>学年</td>
            <td colspan="6">评定结果</td>
            <td>资助金额</td>
          </tr>
          <tr v-for="(grant, index) in grants"
              :key="'info5'+index">
            <td>{{index+1}}</td>
            <td>{{grant.schoolYear}}</td>
            <td colspan="6">{{grant.finalGrantsName}}</td>
            <td>{{grant.money}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>困难补助
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>学年</td>
            <td colspan="6">评定结果</td>
            <td>资助金额</td>
          </tr>
          <tr v-for="(subsidy, index) in subsidys"
              :key="'info6'+index">
            <td>{{index+1}}</td>
            <td>{{subsidy.years}}</td>
            <td colspan="6">{{subsidy.type}}</td>
            <td>{{subsidy.money}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>无息借款
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td>借款批次</td>
            <td colspan="6">评定结果</td>
            <td>借款金额</td>
          </tr>
          <tr v-for="(borrow, index) in borrows"
              :key="'info7'+index">
            <td>{{index+1}}</td>
            <td>{{borrow.loanBatch}}</td>
            <td colspan="6">{{borrow.result}}</td>
            <td>{{borrow.money}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>勤工助学
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td colspan="2">统计年月</td>
            <td colspan="5">岗位名称</td>
            <td>工资</td>
          </tr>
          <tr v-for="(studying, index) in studyings"
              :key="'info8'+index">
            <td>{{ index+1}}</td>
            <td colspan="2">{{studying.yearMonth}}</td>
            <td colspan="5">{{studying.jobName}}</td>
            <td>{{studying.realMoney}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>学费减免
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td colspan="2">学年</td>
            <td colspan="5">减免金额</td>
            <td></td>
          </tr>
          <tr v-for="(tuition,index) in tuitions"
              :key="'info9'+index">
            <td>{{index + 1}}</td>
            <td colspan="2">{{tuition.yearName}}</td>
            <td colspan="5">{{tuition.money}}</td>
            <td></td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>校园地贷款
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td colspan="2">贷款金额</td>
            <td colspan="2">放款年限</td>
            <td colspan="2">借款时间</td>
            <td colspan="2">导入时间</td>
          </tr>
          <tr v-for="(gssl,index) in gssls"
              :key="'info10'+index">
            <td>{{ index+1 }}</td>
            <td colspan="2">{{gssl.money}}</td>
            <td colspan="2">{{gssl.loanYear}}</td>
            <td colspan="2">{{gssl.timeLimit}}</td>
            <td colspan="2">{{gssl.createTime}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>生源地贷款
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td colspan="2">贷款金额</td>
            <td colspan="4">发放年限</td>
            <td colspan="2">导入时间</td>
          </tr>
          <tr v-for="(landloan,index) in landloans"
              :key="'info11'+index">
            <td>{{index + 1}}</td>
            <td colspan="2">{{landloan.money}}</td>
            <td colspan="4">{{landloan.getYear}}</td>
            <td colspan="2">{{landloan.createTime}}</td>
          </tr>
          <tr>
            <td colspan="9"
                class="title">
              <div class="symbol"></div>义务兵代偿
            </td>
          </tr>
          <tr>
            <td>序号</td>
            <td colspan="2">入学年限</td>
            <td colspan="2">代偿金额</td>
            <td colspan="2">发放年限</td>
            <td colspan="2">导入时间</td>
          </tr>
          <tr v-for="(compensation,index) in compensations"
              :key="'info12'+index">
            <td>{{ index + 1 }}</td>
            <td colspan="2">{{compensation.eduYear}}</td>
            <td colspan="2">{{compensation.money}}</td>
            <td colspan="2">{{compensation.getYear}}</td>
            <td colspan="2">{{compensation.createTime}}</td>
          </tr>
          <tr>
            <th colspan="9"
                class="title">成绩情况</th>
          </tr>
          <tr>
            <td>课程名称</td>
            <td>学年</td>
            <td>课程成绩</td>
            <td>学分</td>
            <td colspan="2">成绩类型名称</td>
            <td>课程类型</td>
            <td colspan="2">绩点</td>
          </tr>
          <tr v-for="(score,index) in scores"
              :key="'info13'+index">
            <td>{{score.kcmc}}</td>
            <td>{{score.xn}}</td>
            <td>{{score.kccj}}</td>
            <td>{{score.xf}}</td>
            <td colspan="2">{{score.cjlxmc}}</td>
            <td>{{score.kclx}}</td>
            <td colspan="2">{{score.jd}}</td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>
<script>
import { common } from '@api/index'

export default {
  name: 'printPreview',
  data () {
    return {
      allinformation: {},
      // 基础信息
      basicInformation: {},
      // 教育信息
      education: {},
      // 通讯信息
      contact: {},
      // 违纪处分
      violations: [],
      // 国家助学贷款
      gssls: [],
      // 父母类
      parents: [],
      // 直系亲属类
      consanguinitys: [],
      // 其他社会重要联系人
      linkmans: [],
      // 奖学金
      scholarships: [],
      // 义务兵代偿信息
      compensations: [],
      // 生源地贷款
      landloans: [],
      // 学费减免
      tuitions: [],
      // 勤工助学
      studyings: [],
      // 无息贷款
      borrows: [],
      // 困难补助
      subsidys: [],
      // 助学金
      grants: [],
      // 困难认定
      identifys: [],
      // 成绩情况
      scores: [],
      // 照片
      picUrl: ''
    }
  },
  mounted () {
    if (this.$route.query.type === '1') {
      this.getStudentAllInfo()
    } else if (this.$route.query.type === '2') {
      this.getStudentAllInfoHistory()
    }
  },
  methods: {
    getStudentAllInfo () {
      common()._getStudentAllInfo(this.$route.query.sn).then(res => {
        if (res.status) {
          this.allinformation = res.data
          this.basicInformation = res.data.basic
          this.education = res.data.education
          if (this.education.graduateDate) {
            this.education.graduateDate = this.$moment(this.education.graduateDate).format('YYYY-MM')
          }
          if (this.education.absentee === true) {
            this.education.absentee = '是'
          } else if (this.education.absentee === false) {
            this.education.absentee = '否'
          }
          if (this.education.atSchool === true) {
            this.education.atSchool = '是'
          } else if (this.education.atSchool === false) {
            this.education.atSchool = '否'
          }
          this.contact = res.data.contact
          this.violations = res.data.violations
          if (res.data.violations) {
            for (let i = 0; i < this.violations.length; i++) {
              if (this.violations[i].punishLimit === null) {
                console.log(this.violations[i].punishLimit)
                this.violations[i].punishLimit = '永久'
              }
            }
          }
          this.gssls = res.data.gssls
          this.parents = res.data.parents
          this.consanguinitys = res.data.consanguinitys
          this.linkmans = res.data.linkmans
          this.scholarships = res.data.scholarships
          this.compensations = res.data.compensations
          this.landloans = res.data.landloans
          this.tuitions = res.data.tuitions
          this.studyings = res.data.studyings
          this.borrows = res.data.borrows
          this.subsidys = res.data.subsidys
          this.grants = res.data.grants
          this.identifys = res.data.identifys
          this.picUrl = res.data.picUrl
          // console.log(res.data)
        }
      })
    },
    getStudentAllInfoHistory () {
      common()._getStudentAllInfoHistory(this.$route.query.sn).then(res => {
        if (res.status) {
          this.allinformation = res.data
          this.basicInformation = res.data.basic
          this.education = res.data.education
          if (this.education.graduateDate) {
            this.education.graduateDate = this.$moment(this.education.graduateDate).format('YYYY-MM')
          }
          if (this.education.absentee === true) {
            this.education.absentee = '是'
          } else if (this.education.absentee === false) {
            this.education.absentee = '否'
          }
          if (this.education.atSchool === true) {
            this.education.atSchool = '是'
          } else if (this.education.atSchool === false) {
            this.education.atSchool = '否'
          }
          this.contact = res.data.contact
          this.violations = res.data.violations
          if (res.data.violations) {
            for (let i = 0; i < this.violations.length; i++) {
              if (this.violations[i].punishLimit === null) {
                console.log(this.violations[i].punishLimit)
                this.violations[i].punishLimit = '永久'
              }
            }
          }
          this.gssls = res.data.gssls
          this.parents = res.data.parents
          this.consanguinitys = res.data.consanguinitys
          this.linkmans = res.data.linkmans
          this.scholarships = res.data.scholarships
          this.compensations = res.data.compensations
          this.landloans = res.data.landloans
          this.tuitions = res.data.tuitions
          this.studyings = res.data.studyings
          this.borrows = res.data.borrows
          this.subsidys = res.data.subsidys
          this.grants = res.data.grants
          this.identifys = res.data.identifys
          this.picUrl = res.data.picUrl
          // console.log(res.data)
        }
      })
    }
  }
}
</script>

<style scoped>
.printhead {
  width: 100%;
  height: 50px;
  position: fixed;
  background-color: #e4e4e4;
  top: 0;
  /* z-index: 9999; */
}
.head {
  width: 1400px;
  height: 50px;
  margin: 0 auto;
  line-height: 50px;
}
.content {
  margin-top: 50px;
  background-color: #fff;
}
.tablecontent {
  width: 1400px;
  background-color: #fff;
  margin: 0px auto;
  padding-bottom: 50px;
  text-align: center;
}
table,
th,
td {
  border: 1px solid black;
  text-align: center;
}
table {
  width: 1400px;
  margin-top: 20px;
}
th {
  width: 120px;
  height: 32px;
}
td {
  width: 265px;
  height: 32px;
  /* text-align: left; */
}
.title {
  text-align: left;
}

.symbol {
  width: 10px;
  height: 10px;
  background-color: black;
  border-radius: 50%;
  float: left;
  margin: 4px 15px 0 10px;
}
</style>
